package org.ekstrabilet.main.gui;

import java.awt.event.KeyEvent;

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

import org.ekstrabilet.main.actions.Login;
import org.ekstrabilet.main.actions.Quit;

/**
 * Class that represents application's menu bar.
 *
 */
public class MainMenu {
	
	private JMenuBar menuBar;
	private JMenu menuEdit;
	private JMenuItem menuLogin, menuQuit;
	
	/**
	 * Default constructor.
	 * @param frame reference to main window
	 */
	public MainMenu(MainWindow frame) {
		menuLogin = new JMenuItem("Login", KeyEvent.VK_I);
		menuLogin.setToolTipText("Logs off and goes to 'log in' menu.");
		menuLogin.addActionListener(new Login(frame));
	
		menuQuit = new JMenuItem("Quit", KeyEvent.VK_Q);
		menuQuit.setToolTipText("Exits from the program. All not executed changes will be lost.");
		menuQuit.addActionListener(new Quit(frame));
		
		menuEdit = new JMenu("Edit");
		menuEdit.add(menuLogin);
		menuEdit.add(menuQuit);
		
		menuBar = new JMenuBar();
		menuBar.add(menuEdit);
	}
	
	public JMenuBar getJMenuBar() {
		return menuBar;
	}
}
